#ifndef __THREADPOOL_H__
#define __THREADPOOL_H__
#include <iostream>
#include <memory>
#include <vector>
#include <thread>
#include "TaskQueue.h"
#include <functional>

using std::thread;
using std::unique_ptr;
using std::vector;
using std::function;
using std::bind;

using TASK=function<void()>;

class ThreadPool
{
public:
    ThreadPool(size_t threadNum,size_t queueSize);
    ~ThreadPool();
    void start();
    void stop();
    void addTask(TASK task);
private:
    void doTask();
    TASK getTask();

private:
    size_t _threadNum;
    size_t _queueSize;
    vector<thread> _threads;
    TaskQueue _taskQue;
    bool _isExit;
};

#endif